home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume2 / libraris / remlib.1 < prev   
Internet Message Format  |  1988-11-18  |  24KB

  1. Path: xanth!mcnc!rutgers!mit-eddie!ll-xn!adelie!infinet!ulowell!page
  2. From: page@swan.ulowell.edu (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v02i064:  remlib - remove a library from memory v1.11
  5. Message-ID: <10261@swan.ulowell.edu>
  6. Date: 18 Nov 88 04:42:14 GMT
  7. Organization: University of Lowell, Computer Science Dept.
  8. Lines: 789
  9. Approved: page@swan.ulowell.edu
  10.  
  11. Submitted-by: schabacker@frambo.DEC.COM (Tim, posting for Christian Balzer)
  12. Posting-number: Volume 2, Issue 64
  13. Archive-name: libraries/remlib.1
  14.  
  15. RemLib is an update to the one on Fish #139.
  16. If there are any questions, email me.
  17.  
  18. [uuencoded binary also here, because it's small and the
  19. redistribution requirements state that it must be.  ..Bob]
  20.  
  21. #    This is a shell archive.
  22. #    Remove everything above and including the cut line.
  23. #    Then run the rest of the file through sh.
  24. #----cut here-----cut here-----cut here-----cut here----#
  25. #!/bin/sh
  26. # shar:    Shell Archiver
  27. #    Run the following text with /bin/sh to create:
  28. #    remlib.asm
  29. #    remlib.uu
  30. # This archive created: Thu Nov 17 23:28:05 1988
  31. cat << \SHAR_EOF > remlib.asm
  32. *****************************************************************************
  33. *
  34. * RemLib.asm    by    HEIKO RATH 
  35. *            copyright 1987/88 by the Software Brewery
  36. *
  37. * The purpose of this program is to remove a library from the librarylist.
  38. * To be save, it only removes librarys with an OpenCnt of 0.
  39. * To get a list of all librarys use RemLib without an argument.
  40. *                                Heiko Rath
  41. * Version 1.00 - printed all libraries with one Write (with many libs -> GURU)
  42. * Version 1.01 - prints every row with an extra Write
  43. * Version 1.05 - now features positive and negative size of library
  44. * Version 1.10 - now stops on CTRL-C
  45. * Version 1.11 - worked on error texts
  46. *
  47. *
  48. * This program is
  49. *  
  50. * Copyright (c) 1988 by Heiko Rath and the Software Brewery.
  51. * It may be freely distributed for non-profit only.
  52. * The distribution must contain ALL parts, in this case the following
  53. * files:
  54. * RemLib
  55. * RemLib.asm
  56. * Putting it on a commercial product is usually as easy as sending
  57. * a letter to the author.
  58. *
  59. *****************************************************************************
  60. *______  /          
  61. *______\O                     - The Software Brewery - 
  62. *      \\ 
  63. *       o           Sparkling, fresh software from West-Germany
  64. *
  65. *     @@@@@             Straight from the bar to your Amiga
  66. *     |~~~|\ 
  67. *     | | |/ 
  68. *     |___|        With our regards to the Software Distillery
  69. *
  70. *Christian Balzer alias <CB>, Lattice C, user interfaces, beer addict. 
  71. *Heiko Rath alias <HR>, Assembler, ROM-Kernal stuff, Marabou & beer addict. 
  72. *Ralf Woitinas alias RAF, Assembler, anything, Ray-Tracing addict.
  73. *Andrew Kopp alias Charlie, Aztec C, Hardware & communications, beer addict.
  74. *Armin Sparr alias MARVIN, Aztec C, ARexx macros, Campari addict.
  75. *Christof Bonnkirch alias KEY, Aztec C, Hardware & Devices, beer addict.
  76. *
  77. *Beverages: Altenmuenster Brauer Bier, Urfraenkisches Landbier, Jever.
  78. *
  79. *Send exotic drinks, mail, comments and flames to:
  80. *
  81. *The Software Brewery
  82. *Christian Balzer        UUCP: decwrl!frambo.dec.com!schabacker
  83. *Im Wingertsberg 45        ARPA: schabacker@frambo.dec.com
  84. *D-6108 Weiterstadt        CIS : 71001,210 (be brief!)
  85. *WEST GERMANY (F.R.G.)        Fone: +49 6150 4151 (18:00-21:00 CET!)
  86. *
  87. *
  88. *Send the above stuff, beautiful girls and of course MARABOU-CHOCOLATE to:
  89. *
  90. *Heiko Rath (HHHEEELLLPPP, I'm running out of MARABOU chocolate!!!!!!!)
  91. *Raiffeisenstr.10a
  92. *D-6108 Weiterstadt
  93. *WEST GERMANY (F.R.G.)
  94. *
  95.  
  96. Version        MACRO
  97.         dc.b    '1.11'
  98.         ENDM
  99.  
  100. ExecBase    Equ    4
  101.  
  102. ***
  103. *** Exec Offsets:
  104. ***
  105. OpenLibrary    Equ    -552        ;OpenLibrary (LibName,version)(a1,d0)
  106. CloseLibrary    Equ    -414        ;CloseLibrary (Library)(a1)
  107. Forbid        Equ    -132        ;Forbid ()()
  108. Permit        Equ    -138        ;Permit ()()
  109. AllocMem    Equ    -198        ;AllocMem (bytesize,requirement)(d0,d1)
  110. FreeMem        Equ    -210        ;FreeMem (memoryblock,bytesize)(a1,d0)
  111. FindName    Equ    -276        ;FindName (list,name) (a0,a1)
  112. RemLibrary    Equ    -402        ;RemLibrary (library)(a1)
  113. SetSignal    Equ    -306        ;SetSignal (newSignals,signalMask)(d0,d1)
  114.  
  115. ***
  116. *** DOS Offsets:
  117. ***
  118. OutPut        Equ    -60        ;OutPut ()
  119. Input        Equ    -54        ;Input ()
  120. Write        Equ    -48        ;Write (file,buffer,length)(d1,d2,d3)
  121.  
  122. ***
  123. *** I use these Macros to make things easier for me
  124. ***
  125.  
  126. doit:    MACRO
  127.     move.l    #HeadLine,d2        ;address of HeadLine to d2
  128.     bsr    TextOutPut        ;output HeadLine
  129.     move.l    \1,d0            ;offset of listhead to d0
  130.     bsr    Showlib            ;output library-list
  131.     ENDM
  132.  
  133. ***
  134. *** Here we go:
  135. ***
  136.     move.l    sp,d6            ;store stack pointer on stack
  137.     move.l    a0,a2            ;save cmdline address
  138.     sub.w    #1,d0
  139.     clr.b    0(a2,d0.w)        ;make the cmdline null terminated
  140.  
  141.     move.l    ExecBase,a6        ;Execaddress to a6 (only to be sure)
  142.     move.l    #DOSNAME,a1        ;Librarynamepointer to a1
  143.     moveq    #0,d0            ;any version
  144.     jsr    OpenLibrary(a6)        ;try to open DOS-Libary
  145.     tst.l    d0            ;is d0 = NULL?
  146.     beq    ErrorExit        ;exit if call wasn't successfull
  147.     move.l    d0,DOSBase        ;save DOSBasepointer
  148.     move.l    d0,a6            ;move DOSBasepointer to a6
  149.     jsr    OutPut(a6)        ;identify the initial output handle
  150.     move.l    d0,stdout        ;save stdout
  151.  
  152.     move.l    #Text,d2
  153.     bsr    TextOutPut
  154.  
  155. SkipSP:    
  156.     move.b    (a2)+,d1        ;skip spaces
  157.     beq    ShowTheLibs        ;if NULL-String then /* show librarys */
  158.     cmp.b    #' ',d1            ;is it a Space ?
  159.     beq.b    SkipSP            ;yes -> SkipSP
  160.  
  161.     cmp.b    #'?',d1            ;is it '?' ?
  162.     beq    ShowHow            ;yes -> ShowHow
  163.  
  164.     cmp.b    #'"',d1            ;is it '"' ?
  165.     bne.b    001$            ;yes -> 001$
  166.     add.l    #1,a2
  167.     move.l    a2,a1
  168. 002$:
  169.     move.b    (a1)+,d1
  170.     beq    NoSuchLibrary
  171.     cmp.b    #'"',d1
  172.     beq.b    003$
  173.     bra.b    002$
  174. 003$:
  175.     sub.l    #1,a1
  176.     move.b    #0,(a1)
  177. 001$:
  178.     sub.l    #1,a2            ;decrement address by one
  179.     move.l    ExecBase,a6        ;ExecBase to a6
  180.     move.l    a6,a0            ;ExecBase to a0
  181.     add.l    liblist,a0        ;address of librarylist to a0
  182.     move.l    a2,a1            ;address of string to a1
  183.     jsr    FindName(a6)        ;search for the given name
  184.     tst.l    d0            ;is there a library with the given name
  185.  
  186.     beq.b    NoSuchLibrary        ;no -> NoSuchLibrary
  187.  
  188.     move.l    d0,a1            ;copy address of library to a1
  189.     move.w    32(a1),d0        ;get OpenCnt
  190.     tst.w    d0            ;is the OpenCnt = 0?
  191.     bne.b    NotZero            ;no -> say that the library is still open
  192.     jsr    RemLibrary(a6)        ;try to close the library
  193.     tst.l    d0
  194.     bne.b    Success            ;->Success
  195.  
  196.     move.l    #FailedToRemove,d2
  197.     bsr    TextOutPut
  198.     bra.b    CloseDOS
  199.  
  200. Success:
  201.     move.l    #Successfull,d2
  202.     bsr    TextOutPut
  203.     bra.b    CloseDOS
  204.  
  205. NoSuchLibrary:
  206.     move.l    #NotFound,d2
  207.     bsr    TextOutPut
  208.     bra.b    CloseDOS
  209.  
  210. NotZero:
  211.     move.l    #NotAbleToClose,d2
  212.     bsr    TextOutPut
  213.     bra.b    CloseDOS
  214.  
  215. ShowTheLibs:
  216.     doit    liblist            ;output Librarylist
  217.  
  218. CloseDOS:
  219.     move.l    ExecBase,a6        ;ExecBase to a6
  220.     move.l    DOSBase,a1        ;DOS-pointer to a1
  221.     move.l    ExecBase,a6        ;Exec-pointer to a6
  222.     jsr    CloseLibrary(a6)    ;close DOS
  223. ErrorExit:
  224.     move.l    d6,sp            ;restore stack pointer
  225.     rts                ;CLI here we go again!!!!
  226.  
  227. ShowHow:
  228.     move.l    #HelpText,d2
  229.     bsr    TextOutPut
  230.     bra.b    CloseDOS
  231.  
  232. *****************************************************************************
  233. *
  234. *    Showlib II                11.1.87 modified on 18.10.88
  235. *            by    Heiko Rath
  236. *                Raiffeisenstr.10a
  237. *                D-6108 Weiterstadt
  238. *                WEST GERMANY (F.R.G.)
  239. *
  240. *
  241. * PURPOSE:            print out Librarylist (address of Node,
  242. *                type, priority, name of Node, version, revision,
  243. *                opencount, negative size, positive size)
  244. *
  245. * ROUTINETYPE:            subroutine
  246. *
  247. * SYNTAX:            bsr Showlib    (Exec-offset to librarylist)(d0)
  248. *
  249. * ENTRY CONDITIONS:        needs DOSlibrary opened and stdout defined
  250. *                also needs DOS-'Write' offset -48 defined.
  251. *                It also needs binhex subroutine.
  252. *
  253. * RETURNS:            none
  254. *
  255. * BUGS:                none
  256. *
  257. * NOTE:                none
  258. *
  259. * CHANGED:            nothing
  260. *
  261. * USAGE:            move.l    LibraryListOffset,d0
  262. *                bsr    Showlib
  263. *
  264. *****************************************************************************
  265. Showlib:
  266.     movem.l    d0-d7/a0-a6,-(sp)    ;save registers
  267.  
  268.     move.l    ExecBase,a6        ;ExecBase to a6
  269.     jsr    Forbid(a6)        ;forbid taskswitching (very important,
  270.                     ; 'cause we are accessing Systemdata)
  271.  
  272.     move.l    a6,a0            ;Execpointer to a0
  273.     add.l    d0,a0            ; + librarylistoffset=address of listhead
  274.     move.l    a0,ListHead        ;save address of listheader -=> ListHead
  275.     move.l    (a0),a1            ;get address of 1.Node to a1
  276.     move.l    a1,Node            ;save address of 1.Node -=> Node
  277.     addq.l    #4,a0
  278.     cmp.l    a1,a0            ;list empty?
  279.                     ;(test if listhead points to listhead+4)
  280.     beq    PrintLF            ;yes -=> send LF and exit
  281.  
  282.     moveq.l    #1,d1            ;set counter to 1 'cause there is at least
  283.                     ; one node in the list
  284. MyCountLoop:
  285.     move.l    (a1),a1            ;get address of next node to a1
  286.     tst.l    (a1)            ;see if contents of (a1) is NULL
  287.     beq.b    EndCount        ;leave counting loop
  288.     addq.l    #1,d1            ;increment counter by one
  289.     bra.b    MyCountLoop        ;do this once more
  290.  
  291. EndCount:
  292.     move.l    d1,NodeCount        ;save number of Nodes
  293.  
  294.     move.l    #71,d0            ;number of bytes per node
  295.     mulu    d1,d0            ;bytes per node * NodeCount
  296.     addq.l    #1,d0            ;add one for the bufferterminating Null
  297.     move.l    d0,MyMemoryLength    ;save lenght of Memoryblock
  298.     move.l    #$10001,d1        ;requirements:MEMF_Public & Clear
  299.     jsr    AllocMem(a6)        ;get memory from system
  300.     move.l    d0,MyMemoryBlock    ;save address of Memoryblock
  301.     move.l    d0,MyMemoryOffset    ;save address of Memoryblock 2.time
  302.     tst.l    d0            ;see if call was successfull
  303.     bne    MoveNodeToBuffer    ;yes -=> MoveNodeToBuffer
  304.  
  305.     move.l    #Err,d2            ;this code is only here, to inform the
  306.     bsr    TextOutPut        ; user that the AllocMem call wasn't
  307.     bra    PrintLF            ; successfull
  308.  
  309. MoveNodeToBuffer:
  310.     move.l    d0,a0            ;get address of MemoryBlock to a0
  311.     move.l    MyMemoryLength,d1    ;get length to d1
  312.  
  313. fill:
  314.     move.b    #' ',(a0)+        ;fill MyMemoryBlock with spaces
  315.     dbeq.b    d1,fill            ;is d1=NULL? (no-=>d1=d1-1-=>fill)
  316.  
  317. TheLoop:
  318.     move.l    MyMemoryOffset,a0    ;get address of MyMemoryOffset to a0
  319.     move.l    Node,a1            ;get address of current node to a1
  320.  
  321.     add.l    #10,a1            ;address of namepointer to a1
  322.     move.l    (a1),a1            ;get address of nodename to a1
  323.     moveq.l    #0,d1            ;this is faster than clr.l d1
  324.     moveq.l    #0,d2            ;set this to NULL for strlen
  325.  
  326. strlen:
  327.     cmp.b    (a1)+,d2        ;NULL?
  328.     beq.b    strlentest        ;yes -=>strlentest
  329.     addq.l    #1,d1            ;increment d1 by one (stringlength)
  330.     bra.b    strlen            ;do the loop once more
  331.  
  332. strlentest:
  333.     cmp.b    #20,d1            ;see if string is greater #20
  334.     ble.b    DoCopy            ;no (less or equal)-=>DoCopy
  335.     move.l    #20,d1            ;set max.length to 20
  336.  
  337. DoCopy:
  338.     move.l    Node,a1            ;get address of node to a1
  339.     add.l    #10,a1            ;address of namepointer to a1
  340.     move.l    (a1),a1            ;get address of nodename to a1
  341.     tst.l    d1            ;see if d1=0
  342.     bne    DoTheCopy        ;jump only if d1<>0
  343.     move.l    #NoName,a1        ;get address of NoName to a1
  344.     moveq.l    #7,d1            ;set length to 7 (length of 'No Name')
  345.  
  346. DoTheCopy:
  347.     subq.l    #1,d1            ;decrement d1 by 1
  348.  
  349. CopyLoop:
  350.     move.b    0(a1,d1),0(a0,d1)    ;copy source to destination
  351.     dbf    d1,CopyLoop        ;decrement d1, if d1<0 then out of loop
  352.  
  353.     move.l    MyMemoryOffset,a0    ;get address of MyMemoryOffset to a0
  354.     move.b    #'$',21(a0)        ;store '$'
  355.     move.b    #'$',35(a0)        ;store '$'
  356.     move.b    #10,69(a0)        ;store LF
  357.     move.b    #0,70(a0)        ;store end of string
  358.  
  359.     move.l    Node,a1            ;get Nodeaddress to a1
  360.     addq.l    #8,a1            ;add 8 to get address of Type
  361.     moveq.l    #0,d0            ;clear d0
  362.     move.b    (a1),d0            ;get Type to d0
  363.     move.l    MyMemoryOffset,a0
  364.     add.l    #31,a0
  365.     bsr    bindecb            ;convert to ASCII
  366.  
  367.     move.l    Node,a1            ;get Nodeaddress to a1
  368.     add.l    #9,a1            ;add 1 to get address of Priority
  369.     moveq.l    #0,d0
  370.     move.b    (a1),d0
  371.     move.l    MyMemoryOffset,a0
  372.     add.l    #35,a0
  373.     bsr    bindecb
  374.  
  375.     move.l    Node,a1            ;get Nodeaddress to a1
  376.     add.l    #32,a1            ;add 32 to get address of OpenCnt
  377.     moveq.l    #0,d0            ;clear d0
  378.     move.w    (a1),d0            ;get OpenCnt to d0
  379.     move.l    MyMemoryOffset,a0
  380.     add.l    #39,a0
  381.     bsr    bindecw            ;convert OpenCnt to ASCII
  382.  
  383.     move.l    Node,a1            ;get Nodeaddress to a1
  384.     add.l    #20,a1
  385.     moveq.l    #0,d0
  386.     move.w    (a1),d0            ;Version
  387.     move.l    MyMemoryOffset,a0
  388.     add.l    #45,a0
  389.     bsr    bindecw
  390.  
  391.     move.l    Node,a1
  392.     add.l    #22,a1
  393.     moveq.l    #0,d0
  394.     move.w    (a1),d0            ;Revision
  395.     move.l    MyMemoryOffset,a0
  396.     add.l    #51,a0
  397.     bsr    bindecw
  398.  
  399.     move.l    Node,a1
  400.     add.l    #16,a1
  401.     moveq.l    #0,d0
  402.     move.w    (a1),d0            ;NegSize
  403.     move.l    MyMemoryOffset,a0
  404.     add.l    #57,a0
  405.     bsr    bindecw
  406.  
  407.     move.l    Node,a1
  408.     add.l    #18,a1
  409.     moveq.l    #0,d0
  410.     move.w    (a1),d0            ;PosSize
  411.     move.l    MyMemoryOffset,a0
  412.     add.l    #63,a0
  413.     bsr    bindecw
  414.  
  415.     move.l    Node,d0            ;get Nodeaddress to d2
  416.     move.l    MyMemoryOffset,a0    ;get address of MyMemoryOffset to a0
  417.     add.l    #22,a0            ;add 22 to get storeaddress
  418.     bsr    binhex            ;convert address to ASCII
  419.  
  420.     add.l    #71,MyMemoryOffset    ;do this for the next loop
  421.     move.l    Node,a1            ;get nodeaddress to a1
  422.     move.l    (a1),Node        ;save address of next node
  423.     move.l    MyMemoryOffset,d0    ;get MyMemoryOffset to d0
  424.     addq.l    #1,d0
  425.     move.l    MyMemoryBlock,d1    ;get MyMemoryBlock to d1
  426.     add.l    MyMemoryLength,d1    ;add MyMemoryLength to d1
  427.     cmp.l    d0,d1            ;see if we have to loop once more
  428.     bne    TheLoop            ;if <> -=> TheLoop
  429.     move.l    MyMemoryBlock,a0    ;get address of MyMemoryBlock to a0
  430.     add.l    MyMemoryLength,a0    ;add length to MyMemoryBlock
  431.     subq.l    #1,a0            ;decrement address by one
  432.     move.b    #0,(a0)            ;set last byte of MyMemoryBlock to NULL
  433.  
  434.     move.l    NodeCount,d3        ;get number of nodes to d3
  435.     move.l    MyMemoryBlock,d2    ;get address of MyMemoryBlock to d2
  436. FinallyPrintIt:
  437.     bsr    TextOutPut        ;print one line
  438.     add.l    #71,d2            ;increment string startaddress by 71
  439.     clr.l    d0            ;clear newSignals
  440.     clr.l    d1            ;clear signalMask
  441.     jsr    SetSignal(a6)        ;get the signalmask of our task
  442.     btst    #12,d0            ;is the CTRL-C Bit set?
  443.     bne    CTRL_C_Break        ;if yes -> CTRL_C_Break
  444.     tst.l    d3            ;get desired flag to CCR
  445.     dbeq    d3,FinallyPrintIt    ;is d3=NULL? (no-=>d3=d3-1-=>FinallyPrintIt
  446.  
  447.     move.l    MyMemoryBlock,a1    ;get address of MyMemoryBlock to a1
  448.     move.l    MyMemoryLength,d0    ;get length of MyMemoryBlock to d0
  449.     jsr    FreeMem(a6)        ;free the allocated RAM
  450.  
  451. PrintLF:
  452.     move.l    #LF,d2            ;get address of LF-string to d2
  453.     bsr.b    TextOutPut        ;and get it out via DOS-Write & stdout
  454.     jsr    Permit(a6)        ;permit taskswitching (I think Dos enables
  455.                     ; this for you, but I do this to be sure
  456.                     ; that taskswitching is now allowed.)
  457.     movem.l    (sp)+,d0-d7/a0-a6    ;restore Registers
  458.     rts
  459.  
  460. *****************************************************************************
  461. *
  462. *    TextOutPut
  463. *            by    Heiko Rath
  464. *                Raiffeisenstr.10a
  465. *                D-6108 Weiterstadt
  466. *                WEST GERMANY (F.R.G.)
  467. *
  468. * PURPOSE:         output a NULL-terminated string via stdout
  469. *
  470. * ROUTINE TYPE:     subroutine
  471. *
  472. * SYNTAX:        bsr    TextOutPut    (stringaddress)(d0)
  473. *
  474. * ENTRY CONDITIONS:    needs DOSlibrary opened and stdout defined
  475. *            also needs DOS-'Write' offset -48 defined.
  476. *
  477. * RETURNS:        none
  478. *
  479. * NOTE:            its better if the string is really NULL-terminated
  480. *
  481. * CHANGED:        nothing
  482. *
  483. * USAGE:        move.l    #Textaddress,d2
  484. *            bsr    TextOutPut
  485. *
  486. *****************************************************************************
  487.  
  488. TextOutPut:
  489.     movem.l    d0-d7/a0-a6,-(sp)    ;save registers
  490.     move.l    d2,a0            ;address to a0
  491.     clr.l    d3            ;count = 0
  492.  
  493. CountLoop:
  494.     tst.b    (a0)+            ;is it NULL ?
  495.     beq.b    PMsg            ;yes: -=> determine length
  496.     addq.l    #1,d3            ;count = count+1
  497.     bra.b    CountLoop        ;test next byte
  498.  
  499. PMsg:
  500.     move.l    stdout,d1        ;get stdout to d1
  501.     move.l    DOSBase,a6        ;move DOSBase to a6
  502.     jsr    Write(a6)        ;write the Text
  503.     movem.l    (sp)+,d0-d7/a0-a6    ;reserve registers
  504.     rts
  505.  
  506. ***********************************************************************
  507. *
  508. *     binhex
  509. *             by Heiko Rath
  510. *
  511. * PURPOSE: Convert a binary value in a register to
  512. *        a hex ASCII string at the destination address
  513. *          
  514. * ROUTINE TYPE: SUBROUTINE
  515. *
  516. * SYNTAX: bsr    binhex    (source(long),destination) (d0.l,a0)
  517. *       bsr    binhexw    (source(word),destination) (d0.w,a0)
  518. *       bsr    binhexb    (source(byte),destination) (d0.b,a0)
  519. *
  520. * ENTRY CONDITIONS: None
  521. *
  522. * RETURNS: ASCII string in destination address
  523. * NOTE:     the destination place must contain 8 bytes for any
  524. *            length (byte, word, longword)
  525. *
  526. * CHANGED: Nothing
  527. *
  528. * USAGE:
  529. *
  530. *     move    #label,d0
  531. *     move.l    address,a0    ;converts the address at label to
  532. *     bsr    binhex        ;string at address
  533. *                
  534. *     move    label,d0
  535. *     move.l    address,a0
  536. *     bsr    binhex        ;conv contents at label
  537. *
  538. *     move    #value,d0
  539. *     move.l    address,a0
  540. *     bsr    binhex        ;convert immediate value
  541. *
  542. ****************************************************************
  543.  
  544. binhex:    movem.l    d0-d2/a0,-(sp)        ;save registers
  545.  
  546.     move.l    #7,d2            ;get number of counts to d2
  547.     clr.l    d1            ;clear work register
  548.  
  549. 001$:    rol.l    #4,d0            ;move high nibble to low order
  550.     move.b    d0,d1            ;get low order byte to d1
  551.     andi.b    #$f,d1            ;isolate low order nibble
  552.     cmp.b    #$0a,d1            ;is it a letter or a digit?
  553.     blt.b    002$            ;if digit -=> 002$
  554.     add.b    #'A'-'0'-$0A,d1        ;offset for letters
  555.  
  556. 002$:    add.b    #'0',d1            ;convert to ASCII
  557.     move.b    d1,(a0)+        ;store it and increment storeaddress
  558.     dbf.b    d2,001$            ;do the converting 8 times
  559.  
  560.     movem.l    (sp)+,d0-d2/a0        ;restore registers
  561.     rts
  562.  
  563. ***********************************************************************
  564. *
  565. *     bindec
  566. *             by Heiko Rath
  567. *
  568. * PURPOSE: Convert a binary value in a register to
  569. *        a dec ASCII string at the destination address
  570. *          
  571. * ROUTINE TYPE: SUBROUTINE
  572. *
  573. * SYNTAX:
  574. *       bsr    bindecw    (source(word),destination) (d0.w,a0)
  575. *       bsr    bindecb    (source(byte),destination) (d0.b,a0)
  576. *
  577. * ENTRY CONDITIONS: None
  578. *
  579. * RETURNS: ASCII string in destination address
  580. * NOTE:     the destination place must contain 5 bytes for any
  581. *            length (byte, word). Don't use longwords!
  582. *
  583. * CHANGED: Nothing
  584. *
  585. * USAGE:
  586. *
  587. *     move    #label,d0
  588. *     move.l    address,a0    ;converts the address at label to
  589. *     bsr    bindec        ;string at address
  590. *                
  591. *     move    label,d0
  592. *     move.l    address,a0
  593. *     bsr    bindec        ;conv contents at label
  594. *
  595. *     move    #value,d0
  596. *     move.l    address,a0
  597. *     bsr    bindec        ;convert immediate value
  598. *
  599. ****************************************************************
  600.  
  601. bindecb:
  602.     movem.l    d0-d2/a0,-(sp)        ;store registers
  603.     move.l    d0,d1
  604.     move.l    a0,a1
  605.     bra.b    ByteToDec
  606.  
  607. bindecw:
  608.     movem.l    d0-d2/a0,-(sp)        ;save registers
  609.     move.l    d0,d1
  610.     move.l    a0,a1
  611.  
  612.     divu    #10000,d1
  613.     bsr.b    StoreOneByte
  614.     divu    #1000,d1
  615.     bsr.b    StoreOneByte
  616. ByteToDec:
  617.     divu    #100,d1
  618.     bsr.b    StoreOneByte
  619.     divu    #10,d1
  620.     bsr.b    StoreOneByte
  621.     bsr.b    StoreOneByte
  622.  
  623. 003$:                    ;003$ is used to clear the
  624.     move.b    (a1)+,d0        ; leading zeros
  625.     cmp.b    #'0',d0
  626.     bne.b    002$
  627.     cmp.b    #' ',(a1)
  628.     beq.b    002$
  629.     move.b    #' ',-(a1)
  630.     add.l    #1,a1
  631.     bra.b    003$
  632. 002$:
  633.     movem.l    (sp)+,d0-d2/a0        ;restore registers
  634.     rts
  635.  
  636. StoreOneByte:
  637.     add.b    #$30,d1
  638.     move.b    d1,(a0)+
  639.     clr.w    d1
  640.     swap    d1
  641.     rts
  642.  
  643. CTRL_C_Break:
  644.     move.l    MyMemoryBlock,a1    ;get address of MyMemoryBlock to a1
  645.     move.l    MyMemoryLength,d0    ;get length of MyMemoryBlock to d0
  646.     jsr    FreeMem(a6)        ;free the allocated RAM
  647.  
  648.     move.b    #1,BreakFlag        ;set our internal break flag
  649.     move.l    #BREAK,d2        ;get address of Break-string to d2
  650.     bsr    TextOutPut        ;and get it out via DOS-Write & stdout
  651.     jsr    Permit(a6)        ;permit taskswitching (I think Dos enables
  652.                     ; this for you, but I do this to be sure
  653.                     ; that taskswitching is now allowed.)
  654.     movem.l    (sp)+,d0-d7/a0-a6    ;restore Registers
  655.     rts
  656.  
  657. ***
  658. *** Variables:
  659. ***
  660.  
  661. DOSBase:    dc.l    0        ;this contains the DOSlibraryaddress
  662. stdout:        dc.l    0        ;this contains stdout
  663. stdin:        dc.l    0        ;this contains stdin
  664. ListHead:
  665.     dc.l    0            ;At runtime this contains the
  666.                     ; address of the listheader
  667. Node:
  668.     dc.l    0            ;At runtime this contains the
  669.                     ; address of the current node
  670. NodeCount:
  671.     dc.l    0            ;At runtime this contains the
  672.                     ; number of nodes in the list
  673. MyMemoryLength:
  674.     dc.l    0            ;At runtime this contains the
  675.                     ; length of the memoryblock
  676. MyMemoryBlock:
  677.     dc.l    0            ;At runtime this contains the
  678.                     ; address of the memoryblock
  679. MyMemoryOffset:
  680.     dc.l    0            ;At runtime this contains the
  681.                     ; address of the memoryblock
  682.                     ; + 71 Bytes per finished node
  683. BreakFlag:
  684.     dc.b    0            ;This is set if we encounter a CTRL-C
  685.     cnop    0,2
  686.  
  687. ***
  688. ***Constants:
  689. ***
  690. liblist:    dc.l    $17a
  691.  
  692. DOSNAME:    cstring    'dos.library'
  693.         cnop    0,2
  694. Err:        dc.b    '*** Out of Memory Error ***',0
  695.         cnop    0,2
  696. NoName:        dc.b    'No Name',0
  697.         cnop    0,2
  698. LF:        dc.b    10,0        ;LF
  699.         cnop    0,2
  700. BREAK:        dc.b    '***BREAK',10,0
  701.         cnop    0,2
  702. HeadLine:    dc.b    $9b,'4;32;40m'
  703.         dc.b    'Name                  Address  Typ Pri OpenC'
  704.         dc.b    ' Vers. Revs.  Neg.  Pos.'
  705.         dc.b    $9b,'0;31;40m',10,0
  706.         cnop    0,2
  707. Text:
  708.     dc.b    $9b,'0;33;40m','Lib-Remover',$9b,'0;31;40m '
  709.     dc.b    $9b,'3;31;40m','V'
  710.     Version
  711.     dc.b    $9b,'0;31;40m'
  712.     dc.b    ' by ',$9b,'0;32;40m','Heiko Rath',$9b,'0;31;40m',' - '
  713.     dc.b    $9b,'4;31;40m',169,'1988 by ',$9b,'1;31;40m'
  714.     dc.b    'The Software Brewery',$9b,'0;31;40m',10
  715.     dc.b    'Raiffeisenstr.10a,  D-6108 Weiterstadt,  '
  716.     dc.b    'WEST GERMANY  (F.R.G.)',10,0
  717.  
  718. Successfull:
  719.     dc.b    10,'Succeeded in removing the library.',10,0
  720.     cnop    0,2
  721. NotAbleToClose:
  722.     dc.b    10,$9b,'0;33;40m','Attention:',$9b,'0;31;40m'
  723.     dc.b    ' This library can not be closed, cause OpenCnt > 0.',10,0
  724.     cnop    0,2
  725. FailedToRemove:
  726.     dc.b    10,$9b,'0;33;40m','Attention:',$9b,'0;31;40m'
  727.     dc.b    ' Failed to remove the library.',10,0
  728.     cnop    0,2
  729. NotFound:
  730.     dc.b    10,$9b,'0;33;40m','Attention:',$9b,'0;31;40m'
  731.     dc.b    ' Library not found.',10,0
  732.     cnop    0,2
  733. HelpText:
  734.     dc.b    10,'Use ',$9b,'0;33;40m','Remlib',$9b,'0;31;40m'
  735.     dc.b    ' without argument to display all libraries.',10
  736.     dc.b    'Use ',$9b,'0;33;40m','Remlib',$9b,'0;31;40m'
  737.     dc.b    ' "name.library" to remove a library.',10
  738.     dc.b    'Note: It''s only possible to remove libraries with',10
  739.     dc.b    '      an opencount of 0.',10,0
  740. SHAR_EOF
  741. cat << \SHAR_EOF > remlib.uu
  742.  
  743. begin 644 remlib
  744. M```#\P`````````!``````````````''```#Z0```<<L#R1(4T!",@``+'@`%
  745. M!")\```#^'``3J[]V$J`9P``RB/````#SBQ`3J[_Q"/````#TB0\```$C&$`!
  746. M`LX2&F<``(8,`0`@9_0,`0`_9P``G@P!`")F&%**(DH2&6<``%`,`0`B9P)@1
  747. M\E.)$KP``%.*+'@`!"!.T?H#?")*3J[^[$J`9RHB0#`I`"!*0&8L3J[^;DJ`O
  748. M9@PD/```!=9A``)J8#8D/```!5YA``)>8"HD/```!A1A``)28!XD/```!81A5
  749. M``)&8!(D/```!#1A``(Z(#H#(F$``"(L>``$(GH"\"QX``1.KOYB+D9.=20\"
  750. M```&1F$``A1@X$CG__XL>``$3J[_?"!.T<`CR````]HB4"/)```#WEB(L<EG5
  751. M``':<@$B44J19P12@6#V(\$```/B<$?`P5*`(\````/F(CP``0`!3J[_.B/`'
  752. M```#ZB/````#[DJ`9@``$"0\```$!&$``:A@``&2($`B.@)\$/P`(%?)__H@%
  753. M>@)X(GH"9$/I``HB47(`=`"T&6<$4H%@^`P!`!1O`G(4(GH"1D/I``HB44J!8
  754. M9@``"B)\```$('('4X$1L1``$`!1R?_X('H",A%\`"0`%1%\`"0`(Q%\``H`Q
  755. M11%\````1B)Z`@90B7``$!$@>@(,0>@`'V$``6@B>@'P0^D`"7``$!$@>@'T"
  756. M0>@`(V$``5`B>@'80^D`('``,!$@>@'<0>@`)V$``4(B>@'`0^D`%'``,!$@)
  757. M>@'$0>@`+6$``2HB>@&H0^D`%G``,!$@>@&L0>@`,V$``1(B>@&00^D`$'``)
  758. M,!$@>@&40>@`.6$``/HB>@%X0^D`$G``,!$@>@%\0>@`/V$``.(@.@%@('H!)
  759. M;$'H`!9A``"@!KD```!'```#[B)Z`48CT0```]X@.@%,4H`B.@%"TKH!.K*`L
  760. M9@#^PB!Z`331^@$L4X@0O```)CH!'B0Z`2)A```\!H(```!'0H!"@4ZN_LX(5
  761. M```,9@``Q$J#5\O_XB)Z`/X@.@#V3J[_+B0\```$*&$*3J[_=DS??_].=4CG<
  762. M__X@0D*#2AAG!%*#8/@B.@"X+'H`L$ZN_]!,WW__3G5(Y^"`=`="@>F8$@`"A
  763. M`0`/#`$`"FT"7@$&`0`P$,%1RO_H3-\!!TYU2.?@@"(`(DA@%$CGX(`B`")(?
  764. M@OPG$&$P@OP#Z&$J@OP`9&$D@OP`"F$>81P0&0P``#!F#@P1`"!G"!,\`"!2K
  765. MB6#J3-\!!TYU!@$`,!#!0D%(04YU(GH`0B`Z`#I.KO\N$_P``0```_(D/```@
  766. M!"IA`/]&3J[_=DS??_].=0``````````````````````````````````````Q
  767. M```````````````!>F1O<RYL:6)R87)Y`"HJ*B!/=70@;V8@365M;W)Y($5R?
  768. M<F]R("HJ*@!.;R!.86UE``H`*BHJ0E)%04L*`)LT.S,R.S0P;4YA;64@("`@"
  769. M("`@("`@("`@("`@("!!9&1R97-S("!4>7`@4')I($]P96Y#(%9E<G,N(%)E(
  770. M=G,N("!.96<N("!0;W,NFS`[,S$[-#!M"@";,#LS,SLT,&U,:6(M4F5M;W9EI
  771. M<ILP.S,Q.S0P;2";,SLS,3LT,&U6,2XQ,9LP.S,Q.S0P;2!B>2";,#LS,CLT#
  772. M,&U(96EK;R!2871HFS`[,S$[-#!M("T@FS0[,S$[-#!MJ3$Y.#@@8GD@FS$[^
  773. M,S$[-#!M5&AE(%-O9G1W87)E($)R97=E<GF;,#LS,3LT,&T*4F%I9F9E:7-E*
  774. M;G-T<BXQ,&$L("!$+38Q,#@@5V5I=&5R<W1A9'0L("!715-4($=%4DU!3ED@5
  775. M("A&+E(N1RXI"@`*4W5C8V5E9&5D(&EN(')E;6]V:6YG('1H92!L:6)R87)YG
  776. M+@H```J;,#LS,SLT,&U!='1E;G1I;VXZFS`[,S$[-#!M(%1H:7,@;&EB<F%RT
  777. M>2!C86X@;F]T(&)E(&-L;W-E9"P@8V%U<V4@3W!E;D-N="`^(#`N"@`*FS`[G
  778. M,S,[-#!M071T96YT:6]N.ILP.S,Q.S0P;2!&86EL960@=&\@<F5M;W9E('1HJ
  779. M92!L:6)R87)Y+@H```J;,#LS,SLT,&U!='1E;G1I;VXZFS`[,S$[-#!M($QIO
  780. M8G)A<GD@;F]T(&9O=6YD+@H`"E5S92";,#LS,SLT,&U296UL:6*;,#LS,3LT(
  781. M,&T@=VET:&]U="!A<F=U;65N="!T;R!D:7-P;&%Y(&%L;"!L:6)R87)I97,N1
  782. M"E5S92";,#LS,SLT,&U296UL:6*;,#LS,3LT,&T@(FYA;64N;&EB<F%R>2(@H
  783. M=&\@<F5M;W9E(&$@;&EB<F%R>2X*3F]T93H@270G<R!O;FQY('!O<W-I8FQE)
  784. M('1O(')E;6]V92!L:6)R87)I97,@=VET:`H@("`@("!A;B!O<&5N8V]U;G0@>
  785. M;V8@,"X*`````^P````7`````````!`````B````+@```#0```"8````I```S
  786. M`+````"\````R````.X```$*```!$@```2P```$X```!2````4X```%:```!:
  787. =J````I(```*<```"^````[8```.\`````````_(XY
  788. ``
  789. end
  790. size 1964
  791. SHAR_EOF
  792. #    End of shell archive
  793. exit 0
  794. -- 
  795. Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
  796. Have five nice days.
  797.